/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author orgale
 */
@Entity
@Table(name = "detail_material")
@NamedQueries({@NamedQuery(name = "DetailMaterial.findAll", query = "SELECT d FROM DetailMaterial d"), @NamedQuery(name = "DetailMaterial.findByIdDetailMaterial", query = "SELECT d FROM DetailMaterial d WHERE d.idDetailMaterial = :idDetailMaterial"), @NamedQuery(name = "DetailMaterial.findByName", query = "SELECT d FROM DetailMaterial d WHERE d.name = :name"), @NamedQuery(name = "DetailMaterial.findByValue", query = "SELECT d FROM DetailMaterial d WHERE d.value = :value")})
public class DetailMaterial extends BaseObject implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private Integer idDetailMaterial;
    private String name;
    private String value;
    private Collection<Material> materialCollection;

    public DetailMaterial() {
    }

    public DetailMaterial(Integer idDetailMaterial) {
        this.idDetailMaterial = idDetailMaterial;
    }

    @Id
    @Basic(optional = false)
    @Column(name = "id_detail_material")
    public Integer getIdDetailMaterial() {
        return idDetailMaterial;
    }

    public void setIdDetailMaterial(Integer idDetailMaterial) {
        this.idDetailMaterial = idDetailMaterial;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "value")
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @JoinTable(name = "detail_material_has_material", joinColumns = {@JoinColumn(name = "id_detail_material", referencedColumnName = "id_detail_material")}
                                                    , inverseJoinColumns = {@JoinColumn(name = "id_material", referencedColumnName = "id_material")})
    @ManyToMany
    public Collection<Material> getMaterialCollection() {
        return materialCollection;
    }

    public void setMaterialCollection(Collection<Material> materialCollection) {
        this.materialCollection = materialCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetailMaterial != null ? idDetailMaterial.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof DetailMaterial)) {
            return false;
        }
        DetailMaterial other = (DetailMaterial) object;
        if ((this.idDetailMaterial == null && other.idDetailMaterial != null) || (this.idDetailMaterial != null && !this.idDetailMaterial.equals(other.idDetailMaterial))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.DetailMaterial[idDetailMaterial=" + idDetailMaterial + "]";
    }

}
